package com.imnu.api;

import com.imnu.api.entry.SysUser;
import com.imnu.api.mapper.SysUserMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

import java.util.List;

@SpringBootTest
public class MapperTest {
    @Autowired
    private SysUserMapper sysUserMapper;
    @Test
    public void TestBCryptPasswordEncoder(){
        BCryptPasswordEncoder passwordEncoder=new BCryptPasswordEncoder();
        //加密
         String encode = passwordEncoder.encode("1234");
         String encode1 = passwordEncoder.encode(encode);
        System.out.println(encode);
        System.out.println(encode1);
        //校验:用户输入的密码和数据库中的密文是否一致
        passwordEncoder.matches("12345","$2a$10$5y.uHyeehNlUTwyFKrEUYOjEchV46fp9cLt/48CS.Bw9jQUQG5q5W");

    }

    @Test
    public void testUserMapper(){
        List<SysUser> users = sysUserMapper.selectList(null);
        System.out.println(users);
    }
}
